﻿using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

namespace FortisBC.EnergyEfficiencyCalculator
{
    [ToolboxItemAttribute(false)]
    public class CalculatorWebPart : WebPart
    {
        // Visual Studio might automatically update this path when you change the Visual Web Part project item.
        private const string _ascxPath = @"~/_CONTROLTEMPLATES/FortisBC.EnergyEfficiencyCalculator/CalculatorControl.ascx";

        [Personalizable(), WebBrowsable] 
        public String Rate { get; set; }

        protected override void CreateChildControls()
        {
       //     Control control = Page.LoadControl(_ascxPath);

            CalculatorControl CalcControl = Page.LoadControl(_ascxPath) as CalculatorControl;  
            if (CalcControl != null) 
            {  
                CalcControl.WebPart = this;  
            }

       //     Controls.Add(control);
            Controls.Add(CalcControl);
        }
    }
}
